
#ifndef MEM_POOL
#define MEM_POOL

#include <vector>
#include <cstring>

class memPage_t;
typedef std::vector<memPage_t*> List;

class memPage_t{

	friend class memPool_t;

public:
	int getCurrentPosition() const;

	int setCurrentPosition(int);

	bool empty() const;

	bool full() const;

	int size() const;

	int capacity() const;

	int write(const char*, int, int);

	int write(const char*, int);

	int read(char*, int, int) const;

	int read(char*, int) const;

	~memPage_t();


private:
	char *buffer;

	int SIZE;

	const int CAPACITY;

	int POSITION;

	memPage_t(int);

	memPage_t operator= (const memPage_t&); //non construction copyable

	memPage_t(const memPage_t&); //non-copyable

};




class memPool_t{


public:

	bool empty() const;

	bool full() const;

	int size() const;

	int capacity() const;

	int num_pages() const;

	int getCurrentPosition() const;

	int setCurrentPosition(int);

	int getPageSize() const;

	int setPageSize(int);

	int write(const void*, int, int);

	int write(const void*, int);

	int read(void*, int, int) const;

	int read(void*, int) const;

	memPool_t(int default_size, int num_pages);

	memPool_t(int default_size);

	~memPool_t();

private:

	 List pages;

	 int SIZE;

	 int POSITION;

	 int CAPACITY;

	 static int PAGE_SIZE;

	 void init(int,int);

	 void destroy();

	 memPool_t operator= (const memPool_t&); //non construction copyable

	 memPool_t(const memPool_t&); //non-copyable
};


#endif